home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
utility
/
fortn608.zip
/
FORTUNE.DOC
< prev
next >
Wrap
Text File
|
1996-08-31
|
23KB
|
502 lines
FORTUNE.DOC 1 Revised: 08-31-96
The FORTUNE.EXE program adds some tuning features to the DOS FOR command (FOR
tune, fortune, what the heck). These features can in some way be applied to
commands accepting regular DOS wildcards. Features include:
* Results of command are written to a batch file which you can review before
you run it. Lets you subsequently edit it if desired and lets you see
exactly what commands will happen when you run it.
* You can also try the commands interactively if they don't require that
much memory to run.
* Ability to embed redirection indicators in a command (see next example).
* Ability to separate the file name and file extension. For example:
FORTUNE IN (*.TXT) DO SORT %[ %A %] %1*.SOR
* Ability to identify individual characters in the the file name and extension.
For example:
FORTUNE IN (*.TXT) DO RENAME %A (%1%2%3%4%5%6).*
* Ability to specify a character other than "%" for the delimiter so you can
avoid worrying about different syntax in batch command vs command line.
* Ability to have batch file pause after each command so results can be
reviewed.
* Ability to specify incrementation in the file names. For example:
FORTUNE IN (*.TXT) /+2 DO COPY %A %1*.%0001
* Ability to specify multiple statements on one command line.
* Ability to process children subdirectories (/S option) at same time. For
example:
FORTUNE IN (\*.TXT) /S DO COPY %A D:\BACKUPS
FORTUNE *.BAT /S DEL %A
* Ability to exclude up to 10 file specifications from consideration.
* Ability to do those tough PKZIP commands that you always wanted to do. Like
compress all *.FLI files in your subdirectory to a ZIP of the same name as
the original file:
FORTUNE *.FLI /DO PKZIP -M %R %e
Or move all WAV files into ZIP files with the same name as the WAV file
(separate ZIP for each WAV file):
FORTUNE *.WAV PKZIP -M %R %R.%E
* In addition, you can use the command to create a file which contains a
series of commands including a header and footer section which can be used
for some batch functions.
The DOS FOR command:
Quite a few DOS users are unaware of the DOS FOR command. It allows you to do a
single command over a series of files and provides an easy way to use wildcards
with commands that don't accept them. For example, if you want to type a number
of files to your screen, you can say something like:
FOR %A IN (*.TXT) DO TYPE %A
DOS looks at your IN specification and figures out what file names are covered
by that request. The request can include path information if desired and can
have multiple specification (e.g. "...IN (*.TXT \BAT\*.DOC)...").
FOR then substitutes the file name itself in for whatever variable you specify
in the first parameter after "FOR" ("%A" here). This variable is a single
character (A to Z) preceded by a single percent sign (%). (If FOR is used in a
batch command, you have to use two percent signs (%%) instead.)
FORTUNE.DOC 2 Revised: 08-31-96
FOR then looks at the command following the keyword "DO" and executes that
command. If it finds the variable name in the command, it substitutes the name
of the file for that variable.
So, in the above example, if you had three *.TXT files--ABLE.TXT, BAKER.TXT, and
CHARLIE.TXT--and you ran the command, it would actually do three commands for
you:
TYPE ABLE.TXT
TYPE BAKER.TXT
TYPE CHARLIE.TXT
All in all, FOR is a *very* useful command. There are also some DOS tricks that
you can use to make the command even more useful but, frankly, I always forget
the tricks. (If someone would like to e-mail them to me, I'll throw them in
here.) In any case, even past the tricks, the FORTUNE command provides even more
features.
FORTUNE wildcards and special characters:
The FORTUNE.EXE program extends the functionality of the DOS FOR command by
providing ways of splitting up the parts of the file name and manipulating the
parts. For example, someone in my office had a mess of files that had to be
renamed as an open parenthesis, followed by the first six characters of the file
name, followed by a close parenthesis. Not too terrible to handle with my text
editor but it hadn't occurred to her. Using FORTUNE, however, it's pretty easy:
FORTUNE IN (*.TXT) DO RENAME %A (%1%2%3%4%5%6).*
And then you run the newly-created batch file (DOIT.BAT).
Similarly, someone wanted me to rename a mess of files so they had sequential
names. I had to write a program to handle it. Definitely beyond his
capabilities. Again, using FORTUNE it's pretty easy:
FORTUNE IN *.TXT DO RENAME %A %1*.%0001
And again you run the DOIT.BAT file.
Within the command (DO command), FORTUNE allows you to include a number of
indicators. The character which indicates that it's a special character is
typically "%" but you can change this with the /VAR=char option in FORTUNE. All
of the examples here use the default /VAR=% setting.
NOTE TO 4DOS USERS: 4DOS automatically translates %x characters even if used on
the command line. As such, 4DOS users *have* to use a different /VAR=x setting
to use FORTUNE. FORTUNE detects that you are running 4DOS and typically changes
the default /VAR=% to /VAR=@.
FORTUNE.DOC 3 Revised: 08-31-96
In many cases, the indicators are case sensitive; there's a difference between
%p and %P (presuming the default /VAR=% delimiter). Typically, the lowercase
variants are cumulative. %P gives you just the path whereas %p throws in the
drive information too.
%a translates into the entire file name (begins with drive,
colon, \, path, \, file root, ., file extension).
Use %R.%E if you want the filename without the drive/path info
%D translates into the drive (not followed by :)
%d translates into the drive (followed by :)
%P translates into path (not preceded or followed by \)
%p translates into path (begins with drive, colon, \, path, \)
%R translates into file name root
%r translates into file name root (begins with drive, colon, \,
path, \)
%E translates into file name extension
%e translates into file name extension (begins with drive, colon,
\, path, \, file name root, .)--same as %a
%1 to %8 characters 1 to 8 in the file name root
%X to %Z characters 1 to 3 in file name extension (case insignificant;
%X is the same as %x)
%* replaces the character with the standard "*" wildcard
%? replaces the character with the standard "?" wildcard
Unless preceded by the /VAR=x delimiter, the standard DOS wildcards--"*" and
"?"--are supported within the file name. "...DO RENAME %A Q*.Y*" will actually
generate commands with the letters filled in (if the file name is APPLES.ARE,
the command will be RENAME QPPLES.YRE).
If you want to actually write out the commands and leave in the "*" or "?"
characters, precede the characters with "%" or whatever. For example, "FORTUNE
(*.001) DO COPY %R.0%* %R.TOP" will generate something like "COPY TN960402.0*
TN960402.TOP" whereas "FORTUNE (*.001) DO COPY %R.0* %R.TOP" will generate "COPY
TN960402.001 TN960402.TOP".
All other characters in the command string are passed as given.
FORTUNE.DOC 4 Revised: 08-31-96
Using the above characters, if you have two files C:\AUTOEXEC.BAT and
D:\WAYNE\MYSTUFF.TXT, the various codes above translate as:
C:\AUTOEXEC.BAT D:\WAYNE\MYSTUFF.TXT
%A C:\AUTOEXEC.BAT D:\WAYNE\MYSTUFF.TXT
%D C